// 日期部分
const iTime = document.getElementById('date');
const today = new Date();
const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
iTime.value = today.toISOString().split('T')[0];
// 设置星期几的初始值
document.getElementById('week').innerHTML = days[today.getDay()];
// 将当前日期格式化为 yyyy-MM-dd，并将其设置为日期选择框的最小值
iTime.min = today.toISOString().split('T')[0];
// 最大日期
const maxday = new Date(today);
maxday.setDate(today.getDate() + 14);
iTime.max = maxday.toISOString().split('T')[0];


// 获取选中的日期
iTime.onchange = function () {
  const date = new Date(iTime.value);
  // 获取星期几并显示在页面上
  const dayOfWeek = date.getDay();

  document.getElementById('week').innerHTML = days[dayOfWeek];
}



// 地点部分
const change = document.querySelector('.change');
const startAddress = document.querySelector('.start-address');
const endAddress = document.querySelector('.end-address');

change.addEventListener('click', function () {
  let startAddr = startAddress.value;
  let endAddr = endAddress.value;
  startAddress.value = endAddr;
  endAddress.value = startAddr;
})